//
//  FMTypeTableViewCell.m
//  FunKey
//
//  Created by FC on 15/9/14.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "FMTypeTableViewCell.h"

@implementation FMTypeTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
   self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubview];
    }
    return self;
    
}


-(void)createSubview
{
    
    
    self.backgroundColor = [UIColor blackColor];
    //类型图片
    _myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10 * WIDTH, 15 * HEIGHT,WIDTH * 80, HEIGHT * 80)];
    _myImageView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView addSubview:_myImageView];
    [_myImageView release];
    self.myImageView.layer.masksToBounds = YES;//设置圆角边缘
    self.myImageView.layer.cornerRadius = HEIGHT * 80 / 2;//设置弧度
//
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(110 * WIDTH, 65 * HEIGHT, 100 *WIDTH, 30 * HEIGHT)];
    label.text = @"播放次数:";
    [label setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加粗字体
    label.textColor = [UIColor colorWithHexString:@"FF9966"];
    [self.contentView addSubview:label];
    [label release];
    
    //播放次数
    _playsCounts = [[UILabel alloc]initWithFrame:CGRectMake(190 * WIDTH, 65 * HEIGHT, 100 * WIDTH, 30 *HEIGHT)];
    _playsCounts.text = @"444";
    _playsCounts.textColor = [UIColor colorWithHexString:@"FF9966"];
     [label setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];//加粗字体
    [self.contentView addSubview:_playsCounts];
    [_playsCounts release];
    
    //标题
    _title = [[UILabel alloc]initWithFrame:CGRectMake(110 *WIDTH, 20 *HEIGHT, 230 *WIDTH, 30 *HEIGHT)];
    _title.font = [UIFont systemFontOfSize:19];
    _title.text = @"标题";
    _title.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_title];
    [_title release];
    
    

    
}


-(void)setTypeModel:(FMTypeModel *)TypeModel
{
    
    if (_TypeModel != TypeModel) {
        [_TypeModel release];
        _TypeModel = [TypeModel retain];
    }
    
    
    NSURL *url = [NSURL URLWithString:_TypeModel.albumCoverUrl290];
    [self.myImageView sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"btn_bar_radio@2x.png"]];

    
    self.title.text = _TypeModel.title;
    float number = [_TypeModel.playsCounts floatValue];
    NSString *count = @"";
    if (number > 10000) {
       number = number / 10000;
        count = [NSString stringWithFormat:@"%.1f万",number];
        self.playsCounts.text = count;
        return;
    }
    
    self.playsCounts.text = _TypeModel.playsCounts;

    

}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
